<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>修改分类-azhuo商城</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

	<link rel="shortcut icon" href="${pageContext.request.contextPath }/image/logo/xyz.ico" type="image/x-icon" />
	<link rel="stylesheet" href="${pageContext.request.contextPath }/css/font.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/css/xadmin.css">

	<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
	<script src="${pageContext.request.contextPath }/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/xadmin.js"></script>
	
</head>

<body>
	<div class="x-body">
		<form class="layui-form" method="post" action="${pageContext.request.contextPath }/admin/AdminCategoryServlet">
			<input type="hidden" name="method" value="editCategory" />
			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> <span class="x-red">*</span>分类名称
				</label>
				<div class="layui-input-inline">
					<input type="text" id="cname" name="cname" required="" lay-verify="required" autocomplete="off"
						value="${category.cname }" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="cdesc" class="layui-form-label">分类描述 </label>
				<div class="layui-input-inline">
					<textarea id="cdesc" rows="5" cols="50">${category.cdesc }</textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"> </label>
				<button class="layui-btn" lay-filter="add" lay-submit="">确认修改</button>
			</div>
		</form>
	</div>
	<script>
		layui.use(['form', 'layer'], function () {
			$ = layui.jquery;
			var form = layui.form, layer = layui.layer;

			//自定义验证规则
			// form.verify({
			// });

			//监听提交
			form.on('submit(add)', function (data) {
				console.log("data = " + typeof (data));
				var cname = $("#cname").val();
				var cdesc = $("#cdesc").val();
				console.log("cname = " + cname+",cdesc = "+cdesc);
				//发异步，把数据提交到后台
				layer.alert("修改成功", {
					icon: 6
				}, function () {
					// 获得frame索引
					var index = parent.layer.getFrameIndex(window.name);
					//关闭当前frame
					parent.layer.close(index);
				});

				$.ajax({
					type: "POST",// 请求的方式默认为get 改为Post
					url: "${pageContext.request.contextPath}/admin/AdminCategoryServlet",// 往服务器端请求的地址 写成绝对路径
					data: {
						method: "editCategory",
						cid: "${category.cid }",
						cname: cname,
						cdesc: cdesc
					}// 往服务器端发送的数据
				});
				return false;
			});

		});
	</script>
</body>

</html>